<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.min.js"></script>
</head>
<body>
<div id="app">
    我是父组件中的数据:{{num}} <br>
    <app @btn="cli"></app>
</div>

<script>
    let app = {
        template: `
        <div>
        我是子组件:{{n}}
        <button @click="cli">点我</button>
        </div>
        `,
        data: function () {
            return {
                n: 10
            }
        },
        methods: {
            cli() {
                this.n ++
                this.$emit('btn', this.n)
            }
        }
    }

    new Vue({
        el: '#app',
        data: {
            num: 2,
        },
        methods: {
            cli(t) {
                this.num = t
            }
        },
        components: {
            app: app
        }
    })
</script>
</body>
</html>